package com.belf.console.service.impl;

import com.belf.console.domain.GenerateDataSql;
import com.belf.console.mapper.GenerateDataSqlMapper;
import com.belf.console.service.IGenerateDataSqlService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GenerateDataSqlServiceImpl implements IGenerateDataSqlService {

    @Autowired
    private GenerateDataSqlMapper generateDataSqlMapper;

    @Override
    public void batchInsertSql(List<GenerateDataSql> sqlList, boolean isSave) {
        if (!CollectionUtils.isEmpty(sqlList) && (sqlList.size() >= 500 || isSave)) {
            generateDataSqlMapper.batchInsertSql(sqlList);
            sqlList.clear();
        }
    }
}
